package com.google.code.p.narcissus.ui.listeners;

import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.event.MouseInputAdapter;

public class ReferencePaneMouseEventListener extends MouseInputAdapter {
	
	private boolean mousePressed;
	
	private Rectangle selectionRect;

	public Rectangle getSelectionRect() {
		return selectionRect;
	}

	public void setSelectionRect(Rectangle selectionRect) {
		this.selectionRect = selectionRect;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		

	}

	@Override
	public void mousePressed(MouseEvent e) {
		mousePressed = true;
		selectionRect = new Rectangle();
		selectionRect.setLocation(e.getX(),e.getY());
		selectionRect.setSize(0, 0);
		System.out.println("mousePressed at " + e.getX() + " " + e.getY());
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		mousePressed = false;
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseDragged(MouseEvent e) {
		if(mousePressed){
			selectionRect.setSize(e.getX() - selectionRect.x,e.getY() - selectionRect.y);
			System.out.println("rectaglesiz " +selectionRect.getWidth() + " " + selectionRect.getHeight());
		}
		
	}

	@Override
	public void mouseMoved(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

}
